//École de Technologie Supérieure (ÉTS)
//LOG720 - Laboratoire 3  - Intégration de Spring + Hibernate
//Date de remise: 2011-12-13
//Auteurs:
//Jonathan Aubuchon (AUBJ18038704)
//Jeff Grenier (GREJ02098703)
//Francis Paré (PARF21038708)

package springapp.web;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.view.RedirectView;

import springapp.domain.Dossier;
import springapp.service.DossierCommand;
import springapp.service.DossierManager;

public class CreerDossierController extends SimpleFormController {


	public ModelAndView onSubmit(Object command) throws ServletException {

		DossierCommand ndossier = (DossierCommand) command;

		Dossier d = new Dossier();
		d.setNom(ndossier.getNom());
		d.setPrenom(ndossier.getPrenom());
		d.setNoPermis(ndossier.getNoPermis());
		d.setNoPlaque(ndossier.getNoPlaque());
		DossierManager.getInstance().ajouterDossier(d);

		return new ModelAndView(new RedirectView(getSuccessView()));
	}

	protected Object formBackingObject(HttpServletRequest request)
			throws ServletException {

		DossierCommand dossier = new DossierCommand();
		return dossier;
	}



}
